﻿@model GitCandy.Models.UserModel

@{
    ViewBag.Title = string.Format(SR.Shared_TitleFormat, string.Format(SR.Account_EditTitle, Model.Name));
    var token = GitCandy.Security.Token.Current;
}

<h4>@string.Format(SR.Account_EditTitle, Model.Name)</h4>

<div class="span8">
    @using (Html.BeginForm("Edit", "Account", FormMethod.Post, new { @class = "form-horizontal" }))
    {
        <div class="row">
            @Html.LabelFor(s => s.Name, new { @class = "span3 text-right lead muted" })
            <span class="span1"></span>
            <span class="span4 text-left lead">@Model.Name</span>
            @Html.HiddenFor(s => s.Name, new { @class = "span4 text-left lead" })
        </div>

        <div class="row">
            @Html.LabelFor(s => s.Password, new { @class = "span3 text-right lead muted" })
            <span class="span1"></span>
            @Html.PasswordFor(s => s.Password, new { @class = "span4 text-left lead" })
        </div>
        <div class="row">
            <span class="text-error span5 offset4">
                @Html.ValidationMessageFor(s => s.Password)
            </span>
        </div>

        <div class="row">
            @Html.LabelFor(s => s.Nickname, new { @class = "span3 text-right lead muted" })
            <span class="span1"></span>
            @Html.TextBoxFor(s => s.Nickname, new { @class = "span4 text-left lead" })
        </div>
        <div class="row">
            <span class="text-error span5 offset4">
                @Html.ValidationMessageFor(s => s.Nickname)
            </span>
        </div>

        <div class="row">
            @Html.LabelFor(s => s.Email, new { @class = "span3 text-right lead muted" })
            <span class="span1"></span>
            @Html.TextBoxFor(s => s.Email, new { @class = "span4 text-left lead" })
        </div>
        <div class="row">
            <span class="text-error span5 offset4">
                @Html.ValidationMessageFor(s => s.Email)
            </span>
        </div>

        <div class="row">
            @Html.LabelFor(s => s.Description, new { @class = "span3 text-right lead muted" })
            <span class="span1"></span>
            @Html.TextAreaFor(s => s.Description, 4, 0, new { @class = "span4 text-left lead" })
        </div>
        <div class="row">
            <span class="text-error span5 offset4">
                @Html.ValidationMessageFor(s => s.Description)
            </span>
        </div>

        if (token.IsSystemAdministrator)
        {
            <div class="row">
                @Html.LabelFor(s => s.IsSystemAdministrator, new { @class = "span3 text-right lead muted" })
                <span class="span1"></span>
                <div class="switch switch-small" data-on-label="@SR.Shared_Yes" data-off-label="@SR.Shared_No">
                    @Html.CheckBoxFor(s => s.IsSystemAdministrator)
                </div>
            </div>
            <div class="row">
                <span class="text-error span5 offset4">
                    @Html.ValidationMessageFor(s => s.IsSystemAdministrator)
                </span>
            </div>
        }

        @Html.ValidationSummary(true, SR.Account_UpdateUnsuccessfull, new { @class = "alert alert-error" })

        <div class="form-actions">
            <div class="pull-left">
                @Html.ActionLink(SR.Shared_Back, "Detail", new { Model.Name }, new { @class = "btn" })
            </div>
            <div class="pull-right">
                @if (token.IsSystemAdministrator)
                {
                    @Html.ActionLink(SR.Shared_Delete, "Delete", new { Model.Name }, new { @class = "btn" })
                }
                <button type="reset" class="btn btn-inverse">@SR.Shared_Reset</button>
                <button type="submit" class="btn btn-primary">@SR.Shared_Save</button>
            </div>
        </div>
    }
</div>
